/**
 * Created by Administrator on 2017/4/25.
 */
let sqlStatement = require ('../utils/DB/MysqlStatement');


module.exports = {
    findMovieInfoByOpenid:function(param, callBack){
        let sqlStr = 'SELECT upi.mid,upi.endtime FROM sarft_playinfo upi INNER JOIN movie ON upi.mid = movie.mid where upi.openid = ? and valid_status = 0 ORDER BY upi.createtime DESC limit ?,10';
        let arr = [param.openId,param.lastIndex];
        sqlStatement.sqlStatement([sqlStr,arr],function(data){
            if(data.isSuccess){
                callBack({
                    isSuccess:true,
                    result:data.result
                });
            }else {
                callBack({
                    isSuccess:false
                });
            }
        })
    },
    findCinemaInfoByOpenid:function(param, callBack){
        let sqlStr = 'SELECT upi.cid,upi.endtime FROM sarft_playinfo upi INNER JOIN cinema ON cinema.cinema_code = upi.cid  where upi.openid = ? and valid_status = 0  GROUP BY upi.cid,upi.createtime ORDER BY upi.createtime DESC limit ?,10';
        let arr = [param.openId,param.lastIndex] ;
        sqlStatement.sqlStatement([sqlStr,arr],function(data){
            if(data.isSuccess){
                callBack({
                    isSuccess:true,
                    result:data.result
                });
            }else {
                callBack({
                    isSuccess:false
                });
            }
        })
    }
};
